home *** CD-ROM | disk | FTP | other *** search
-
- double setsigdig(double x, unsigned int n)
- {
- double shift, result;
-
- if ((n == 0U) || (n > DBL_DIG))
- result = x;
- else
- {
- // adjust the number of significant digits
- --n;
-
- // calculate the number of digits to be shifted
- shift = pow(10.0,(double)n
- - floor(log10(fabs(x))));
-
- result = tonearest(x * shift) / shift;
- }
-
- return result;
- }
-
-